/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/12/11 17:20
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.uaa.model;

import com.spring.arch.common.jpa.model.AbstractPersistableModel;
import com.spring.arch.common.jpa.model.AbstractPersistableModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 组织人员信息
 *
 * @author Frank
 * @version 1.0.0.1
 * @since 2019/12/11 17:20
 */
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "organization_employee")
public class OrganizationEmployee extends AbstractPersistableModel {

    private static final long serialVersionUID = 9150653327262075185L;

    /**
     * 组织信息
     */
    @NotNull
    @ManyToOne(fetch = FetchType.EAGER)
    private Organization organization;

    /**
     * 人员信息
     */
    @NotNull
    @ManyToOne(fetch = FetchType.EAGER)
    private TenantEmployee employee;

    /**
     * 用户信息，对应关联OrganizationEmployeeRole
     */
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
    private User user;

    /**
     * 状态(true: 正常， false： 锁定)
     */
    @NotNull
    private Boolean status = true;

    public OrganizationEmployee(@NotNull Organization organization, @NotNull TenantEmployee employee, User user) {
        this.organization = organization;
        this.employee = employee;
        this.user = user;
    }
}
